home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-04-29 | 9.8 KB | 550 lines | [TEXT/MPS ] |
- /* There is a "\n" after the "{" */
- int a[] = {1,2,3,4};
-
- /* The "T::*a" was being emitted as "T ::*a" */
- void (Target::*aMethod)(int);
-
- /* The "b" appears flush left in the output instead of being indented */
- int a,// comment
- b;
- Rect a,// More commentary
- b;
-
- /* The following causes a rescan. The rescan screws up */
- void ObjectTable::IObjectTable(PageTable* aPageTable,
- unsigned short firstPage,
- unsigned long nObjectsInFile,
- unsigned short objectSize)
-
-
- /* The "," yields ", " instead of ", " */
- foo(){int a,b;}
-
- /*
- this is a comment
-
- with a blank line
- */
-
- int x = {
- /*
- ** a comment
- */
- 1,
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdefghijklmnopqrstuvwxyz",
- };
-
- // The "int x;" is indented. Why is that?
- RedoPageBreaks()
- {
- a, b;
- a, b;
- }
- int x;
-
-
- foo(){return x;return (foo*)(x);}
- aType foo(OSType fileCreator // a comment
- ){}
- foo(){do ch = NextChar();while ((ch > 0) && (ch != '\n'));}
-
- foo(){*a++==&p;a=-1;*a++=&p;*a++==&p;- -q;}
-
- static short itemList[] =
- {
- 3, /* max number of items - 1 */
-
- /*
- ** statText item
- */
- 0, 0, /* reserve a Longint for item handle */
- 10, 27, 61, 225, /* display rectangle */
- ((8 + 128) << 8) | 8, /* 8 + 128 = statText (disabled), title 8 bytes long */
- '^0', '^1', /* ^0^1^2^3 */
- '^2', '^3',
-
- /*
- ** first button
- */
- 0, 0, /* reserve a Longint for item handle */
- 104, 140, 124, 210, /* display rectangle */
- (4 << 8) | 0, /* 4 = pushButton, title is 0 bytes long*/
-
- /*
- ** second button
- */
- 0, 0, /* reserve a Longint for item handle */
- 104, 30, 124, 100, /* display rectangle */
- (4 << 8) | 0, /* 4 = pushButton, title is 0 bytes long */
-
- /*
- ** third button
- */
- 0, 0, /* reserve a Longint for item handle */
- 72, 30, 92, 100, /* display rectangle */
- (4 << 8) | 0 /* 4 = pushButton, title is 0 bytes long */
- };
-
- class
- {
- String() {}
- // Return the string in the token itself
- };
-
-
- foo ()
- {
- if (q)
- {
- }
-
- // Skip over the white space
- Fnord();
- //ƒ-
- /*ƒ-turn off comments
- */
- a(b, c, d);
- //ƒ+
- a(b, c, d);a(b, c, d);a(b, c, d);a(b, c, d);
- }
-
-
- #define initialMasters 1024 /* masters pointers to reserve at startup
- up from 700 kc 7/20/90 */
-
-
- typedef struct OpEntry { /* Operator table entry */
- TokenKind operator; /* token type (LeftParen, Plus, …) */
- unsigned char precedence; /* operator precedence */
- OpKind opKind; /* operator type (unary, binary, …) */
- OperandKind operandKind; /* type of operands (string, integer, …) */
- State (*expectOperandFn)(); /* routine to call when expecting operand */
- State (*expectOpFn)(); /* routine to call when expecting operator */
- } OpEntry;
-
-
- pjDiskInsert(EventRecord* pEvent, PCommonStruct pCommon)
- {
- short drive;
- VCB *pVCB;
- QHdrPtr qHead;
- short vol;
-
- if (pCommon->type == CheckInWindow || pCommon->type == NewProjectWindow
- #ifndef BROWSER
- )
- #else
- || pCommon->type == kBrowserWindow)
- #endif
- {
- // if private is not specified, set public by default
- // (first verify that we can't get here with them both set)
- BugAssert((!opt.private || !opt.public), "Public & private options are equal!");
- opt.public = !(opt.private);
- }
- fixThis();
- #if 0
- else {
- updateNamePopup(projectIndex);
- }
- #endif
- }
-
-
-
- #ifdef ghs
- pascal void
- scrollText(hScroll, thePart)
- ControlHandle hScroll; /* scroll bar's handle */
- short thePart; /* the part of the control the mouse is in */
- #else
- pascal void scrollText(ControlHandle hScroll, short thePart)
- #endif
- {
- }
-
-
-
- foo()
- {
- if(1){}
- else;
- if (1) ; else if (1) ; else if (1) {}
- else if (1)
- {} else { gCrashCause = kBreakPoint;
- }
-
- if (maxBytesOnCont == 6)
- TABTO(hexcodeCol - 1)
- else
- TABTO(hexcodeCol + 5 - 1)
-
- struct {
- unsigned inFindNextMode : 1; } sally;
- }
-
-
- foo(int a, int b)
- {
- short targetSize, maskSize, e, m, t;
- char* inputBuffer = new char[inputSize+1];
- }
-
-
-
-
- typedef struct // OpndInfo set up by Interpret's Get1Opnd
- {
- } OpndInfo, *pOpndInfo;
-
-
- typedef pascal OSErr (*VNProcPtr)(VolumeNoticeBlkPtr pParams);
-
- void* operator()();
-
-
- #ifdef __cplusplus
- extern "C" {
- #endif __cplusplus
- pascal SetFont(unsigned char *fName, short fontKind, short fontSize);
- /*
- Set the MPW editor font kind and size. No errors are returned of this
- operation fails.
- */
-
- #ifdef __cplusplus
- }
- #endif __cplusplus
-
-
-
- typedef struct FILE_REFERENCE FILE_REFERENCE;
-
- foo(){TTE_INFO type1, type2, type3;}
-
-
- struct{};
-
- enum
- {
- kSErr = -1 // Error token
- , kSLex = 0 // Base enum for scanner generated tokens
- , kSPrs = 1000 // Base class for parser generated items
- };
-
-
- operator FILE*() const {return (fFile);}
-
-
-
- class Formatting;
-
-
- extern void diag(Severity, const char*, ...); /* Report errors */
-
-
- #define CASE(a) case a: return (#a);
- const char*
- Parser::NameOf(short aType)
- {
- switch (aType)
- {
- CASE(kSPrs_DeclOperator)
-
- default: return "<unknown token>";
- }
- }
-
-
-
- foo(){}
-
-
- Parser::~Parser()
- {}
-
-
-
-
- foo()
- {
- static const short handles[] =
- {
- 4, kSLex_Id, 4, kSLex_Id, kSLex_ClassColon, kSLex_OpBNot, kSPrs_Id,
-
- -1, -1, 0
- };
- }
-
-
- foo()
- {
- for (;;)
- {
- ch=NextChar();
- }
- }
-
-
-
- foo()
- {
- if (strncmp((char*)fBuffer-1, "if", 2)==0)
- type=kSLex_PoundIf;
- else if (strncmp((char*)fBuffer-1, "endif", 5)==0)
- type=kSLex_PoundEndIf;
-
- ;;;
- }
-
-
- foo()
- {
- if (strncmp((char*)fBuffer-1, "if", 2)==0)
- for (;;)
- {
- ch=NextChar();
- if (ch=='\\'&&NextChar()=='\n')
- continue;
- if (IsEOF()||ch=='\n')
- {
- if (ch=='\n')
- PushBack();
- return (new CommentToken(type, start, fBuffer));
- }
- if (findFirstWord&&!isspace(ch))
- {
- findFirstWord=false;
- if (strncmp((char*)fBuffer-1, "if", 2)==0)
- type=kSLex_PoundIf;
- else if (strncmp((char*)fBuffer-1, "elif", 4)==0)
- type=kSLex_PoundElif;
- else if (strncmp((char*)fBuffer-1, "else", 4)==0)
- type=kSLex_PoundElse;
- else if (strncmp((char*)fBuffer-1, "endif", 5)==0)
- type=kSLex_PoundEndIf;
- }
- }
- }
-
- foo()
- {
- while (isxdigit(ch))
- ch = NextChar();
- }
-
-
- static PredefinedToken gClassColon (kSLex_ClassColon, "::");
-
- static unsigned char gErrText[] = "——— Error ———";
- static LexicalToken gErr (kSErr, gErrText, gErrText+13);
-
- void
- CommentToken::Display(Formatting* aFormat)
- {
- switch (Type())
- {
- case kSLex_Comment:
- aFormat->Comment((const char*)fStart, (const char*)fEnd);
- break;
-
- case kSLex_PoundIf:
- case kSLex_PoundElif:
- case kSLex_PoundElse:
- case kSLex_PoundEndIf:
- case kSLex_PoundOther:
- /*
- ** Assure that the preprocessor line starts on a fresh line
- */
- aFormat->FreshLine();
- // !!! FALL THROUGH !!!
-
- default:
- aFormat->Write((char*)fStart, fEnd-fStart);
- break;
- }
- }
-
-
-
- /*
- ** Define the types that parse items can be.
- */
- enum
- {
- kSLex_ParsedId = kSLex_Last+1 // The "id" has been parsed.
- , kSLex_Flush // Unblocks Prs_Id/Prs_DeclOperator
-
- , kSPrs_Id = kSPrs // Base parse type
- , kSPrs_StmtList
- , kSPrs_DeclList
- , kSPrs_DeclType
- , kSPrs_Stmt
- , kSPrs_Decl
- , kSPrs_Do
- , kSPrs_If
- , kSPrs_Else
- , kSPrs_For
- , kSPrs_Struct
- , kSPrs_Switch
- , kSPrs_While
- , kSPrs_Expr
- , kSPrs_DeclOperator
- };
-
-
- /*
- ** LexicalToken
- ** This class represents tokens whose body is in the CScanner buffer itself
- */
- class LexicalToken : public SyntacticLex
- {
- public:
- LexicalToken(short aType, TextPtr start)
- : SyntacticLex(aType)
- , fStart(start)
- , fEnd(start+strlen((char*)start))
- {}
-
- LexicalToken(short aType, short aMinorType, TextPtr start)
- : SyntacticLex(aType, aMinorType)
- , fStart(start)
- , fEnd(start+strlen((char*)start))
- {}
-
- LexicalToken(short aType, TextPtr start, TextPtr end)
- : SyntacticLex(aType)
- , fStart(start)
- , fEnd(end)
- {}
-
- LexicalToken(short aType, short aMinorType, TextPtr start, TextPtr end)
- : SyntacticLex(aType, aMinorType)
- , fStart(start)
- , fEnd(end)
- {}
-
- virtual void Display(Formatting* aFormat);
- /*
- ** Display the token using the formatting information given by
- ** aFormat
- */
-
- protected:
- TextPtr fStart;
- TextPtr fEnd;
- };
-
-
- void
- LexicalToken::Display(Formatting* aFormat)
- {
- aFormat->Write((char*)fStart, fEnd-fStart);
- }
-
-
-
-
- class SyntacticLex : public Syntactic
- {
- public:
- SyntacticLex(int aType, int aMinorType=0)
- : Syntactic(aType, aMinorType)
- {}
-
-
- virtual Boolean IsSeparator() const;
- /*
- ** Return true.
- */
-
- virtual const Syntactic* SaveCopy() const;
- /*
- ** The object cannot be modified by any of its methods, so
- ** return itself.
- */
-
- virtual void Display(Formatting* aFormat) = 0;
- /*
- ** Format and display this syntactic item. The format to use when
- ** displaying is passed in as its only argument.
- */
- };
-
- #define CASE(x) {#x, &gFS_##x},
- static Boolean
- isFormatOption(int argc, char* argv[], int i)
- {
- if (i+1 >= argc)
- return (false);
-
- const char* aName = argv[i]+1;
- const char* aFormat = lower(argv[i+1]);
-
- static struct Option
- {
- const char* fName;
- FormatString* fString;
- } options[] =
- {
- CASE(fundef2)
- CASE(fundef3)
- CASE(fundef4)
- CASE(fundef6)
- CASE(fundef7)
- CASE(fundef8)
- CASE(fundef10)
- CASE(fundef11)
- CASE(fundef12)
- CASE(fundef13)
- CASE(fundef14)
-
- CASE(decl0)
- CASE(decl1)
- CASE(decl2)
- CASE(decl3)
- CASE(decl5)
- CASE(decl6)
- CASE(decl7)
- CASE(decl8)
- CASE(decl9)
- CASE(decl10)
- CASE(decl11)
- {0, 0}
- };
-
- return (false);
- }
-
-
- Boolean
- SyntacticLex::IsSeparator() const
- {
- return (false);
- }
-
-
- const Syntactic*
- SyntacticLex::SaveCopy() const
- {
- return (this);
- }